package com.lrkj.waitress.task;


import com.lrkj.common.constant.FeeConstants;
import com.lrkj.common.core.domain.entity.OrgTree;
import com.lrkj.lease.domain.LeaseContract;
import com.lrkj.lease.mapper.LeaseContractMapper;
import com.lrkj.lease.service.IContractCategoryService;
import com.lrkj.payfee.domain.RoomNorm;
import com.lrkj.payfee.service.IChargeItemService;
import com.lrkj.payfee.service.IChargeNormService;
import com.lrkj.payfee.service.IRoomNormService;
import com.lrkj.payfee.service.IRuleCostService;
import com.lrkj.property.domain.Room;
import com.lrkj.property.mapper.RoomMapper;
import com.lrkj.property.service.IRoomService;
import com.lrkj.system.service.IOrgTreeService;
import com.lrkj.waitress.service.ICustomInfoService;
import com.lrkj.waitress.service.IRoomCustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 定时修改租赁合同到期
 */
@Component("leaseTask")
public class leaseTask {


    @Autowired
    private LeaseContractMapper leaseContractMapper;


    @Autowired
    private IRoomCustomService roomCustomService;

    @Autowired
    private IOrgTreeService orgTreeService;

    @Autowired
    private IRoomNormService roomNormService;

    @Autowired
    private RoomMapper roomMapper;


    @Transactional
    public void eachLeaseTask(){
        List<LeaseContract> contractList = leaseContractMapper.selectLeaseResoId(new LeaseContract());
        contractList.stream().forEach(x->{
            x.setStatus("30");
            leaseContractMapper.updateLeaseContract(x);

//            OrgTree orgTree=new OrgTree();
//            orgTree.setId(x.getResourceId());
//            orgTree.setOwnerName("");
//            //修改组织树 清空客户名称
//            orgTreeService.updateOrgTree(orgTree);
//
//            //删除绑定租户房间
//            roomCustomService.deleteRoomCustomById(x.getResourceId());
//
//            //房屋收费标准状态改为收费结束
//            RoomNorm roomNorm=new RoomNorm();
//            roomNorm.setRoomId(x.getResourceId());
//            roomNorm.setStatus(FeeConstants.room_norm_status_10002);
//            roomNormService.updteByRoomId(roomNorm);
//
//            //修改房间状态
//            Room room=new Room();
//            room.setId(x.getResourceId());
//            room.setState("10001");
//            room.setStatusCd("1001");
//            roomMapper.updateRoomState(room);
        });

    }

}
